package cn.zhuwj.autodiscovery;

import cn.zhuwj.autodiscovery.config.StartConfig;

/**
 * @author zhuwj.cn
 */
public class AutoDiscoveryStarter {

    /**
     * 开始自动发现端口是否开放
     * @param callback
     * @throws InterruptedException
     */
    public static void start(StartConfig.Callback callback) throws InterruptedException {
        StartConfig config = new StartConfig();
        config.setCallback(callback);
        start(config);
    }

    /**
     * 开始自动发现端口是否开放
     * @param ip
     * @param port
     * @param callback
     * @throws InterruptedException
     */
    public static void start(String ip, Integer port, StartConfig.Callback callback) throws InterruptedException {
        StartConfig config = new StartConfig();
        config.setIp(ip);
        config.setPort(port);
        config.setCallback(callback);
        start(config);
    }

    /**
     * 开始自动发现端口是否开放
     * @param startIp
     * @param endIp
     * @param startPort
     * @param endPort
     * @param callback
     * @throws InterruptedException
     */
    public static void start(String startIp, String endIp, Integer startPort, Integer endPort, StartConfig.Callback callback) throws InterruptedException {
        StartConfig config = new StartConfig();
        config.setStartIp(startIp);
        config.setEndIp(endIp);
        config.setStartPort(startPort);
        config.setEndPort(endPort);
        config.setCallback(callback);
        start(config);
    }

    /**
     * 开始自动发现端口是否开放
     * @param config
     * @throws InterruptedException
     */
    public static void start(StartConfig config) throws InterruptedException {
        AutoDiscovery autoDiscovery = new AutoDiscovery(config);
        autoDiscovery.start();
    }
}
